﻿using MRMDS_Client;
using Sharprompt;

Console.OutputEncoding = System.Text.Encoding.Unicode;
if (!Prompt.Confirm("Welcom use MRMDS CSharp Client Bind Demo,Start?", true))
{
    return;
}
tokenL:
string token = Prompt.Input<string>("Input your token:");
string root = Prompt.Input<string>("Input your root path[http://localhost]:");
int port = Prompt.Input<int>("Input your port[5000]:");
var bind = new ClientAPIBind(token);
bind.Connect(root, port);
if (!Prompt.Confirm("Login?", true))
{
    bind.Dispose();
    goto tokenL;
}
var type = Prompt.Select<ClientAPIBind.ClientType>("Select client type:");
if (!bind.Login(type, out string? uuid))
{
    Console.WriteLine("LoginError");
    return;
}
Console.WriteLine($"uuid:{uuid}");
string function = Prompt.Select("Chose function:", new string[] { "Update Info", "Update State", "Logout" });
switch (function)
{
    case "Update Info":
        break;
    case "Logout":
        if (!bind.Logout())
        {
            Console.WriteLine("LogoutError");
            return;
        }
        break;
}
